import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/yt_text_style.dart';
import 'package:yt_devops/components/my_gesture_detector.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';

/**
 *
 * @Description TODO
 * @Author liuer
 * @CreateTime 2024年03月20日 17:01
 */
class AlarmTitleWidget extends StatefulWidget {
  final Function(int) callBack;
  const AlarmTitleWidget(this.callBack,{super.key});

  @override
  State<AlarmTitleWidget> createState() => _AlarmTitleWidgetState();
}

class _AlarmTitleWidgetState extends State<AlarmTitleWidget> {
  int selectedIndex = 0;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Spacer(),
        MyGestureDetector(onTap: () {
            setState(() {
              selectedIndex = 0;
              widget.callBack(selectedIndex);
            });
        }, child: Text(
          ResKey.currentAlarm.tr,
          style: ytTextStyle(
              fontSize: selectedIndex == 0?18:16,
              fontWeight: selectedIndex == 0?FontWeight.w500:FontWeight.normal,
              color: selectedIndex == 0
                  ? Colour.mainTextColor
                  : Colour.lightTextColor),
        )),
        Gaps.hGap24,
        MyGestureDetector(onTap: () {
          setState(() {
            selectedIndex = 1;
            widget.callBack(selectedIndex);
          });
        }, child: Text(
          ResKey.historyAlarm.tr,
          style: ytTextStyle(
              fontSize: selectedIndex == 1?18:16,
              fontWeight: selectedIndex == 1?FontWeight.w500:FontWeight.normal,
              color: selectedIndex == 1
                  ? Colour.mainTextColor
                  : Colour.lightTextColor),
        ),),
        Gaps.hGap40,
        Spacer(),
      ],
    );
  }
}
